from .models import imageInfo
from .models import push_log
from rest_framework import serializers

class ImageDetailSerializer(serializers.ModelSerializer):
    # 镜像列表

    create_time = serializers.DateTimeField(format="%Y-%m-%d %H:%M:%S")
    update_time = serializers.DateTimeField(format="%Y-%m-%d %H:%M:%S")

    class Meta:
        model = imageInfo
        fields = "__all__"


class ImagePushDataSerializer(serializers.Serializer):
    # 用于在镜像推送成功或失败时返回数据

    name = serializers.CharField(max_length=30,label="名称",help_text="名称")
    tag = serializers.CharField(max_length=20,label="标签",help_text="标签")
    push_env = serializers.CharField(max_length=10,label="目标环境",help_text="目标环境")
    push_time = serializers.DateTimeField(format="%Y-%m-%d %H:%M:%S")
    status = serializers.BooleanField(label="推送状态",help_text="推送状态")



class ImageHistoryPushRecordSerializer(serializers.ModelSerializer):
    '''推送历史记录'''

    push_time = serializers.DateTimeField(format="%Y-%m-%d %H:%M:%S")

    class Meta:
        model = push_log
        fields = "__all__"
